﻿using System.Linq;
using System.Text;
using System.Diagnostics;
using System.Runtime.Serialization;
using System.Collections;
using System.Data;
using System.ComponentModel;
using System.Data.OracleClient;
using WPFExcelReport.Helpers;
using WPFExcelReport.Controls;
namespace WPFExcelReport
{

    public partial class VICC_SRULES
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {

            switch (app.company)
            {
                case "YGR":
                case "YCC":
                default:
                    dwReturn["ROWNID"] = INTEXDBC.GetSeq();
                    dwReturn["MACHINEID"] = "M_SZ";
                    dwReturn["RGROUP"] = "30";
                    dwReturn["RULEID"] = "6";
                    dwReturn["JOBV"] = "JP04";
                    dwReturn["JOBVDES"] = "Æ·ÖÖ×é";
                    dwReturn["LOGIC"] = "=";
                    dwReturn["RVALUE"] = "Z";
                    dwReturn["RULEDES"] = "Æ·ÖÖ×é=Öñ½ÚÉ´";
                    dwReturn["POINTS"] = "100";
                    dwReturn["JOBNUM"] = "0";
                    dwReturn["LASTEND"] = "0";
                    dwReturn["JMVALUE"] = "0";
                    dwReturn["JJVALUE"] = "0";
                    dwReturn["JOBID"] = "0";
                    dwReturn["JP01"] = "0";
                    dwReturn["JP02"] = "0";
                    dwReturn["JP03"] = "0";
                    dwReturn["JP04"] = "0";
                    dwReturn["JP05"] = "0";
                    dwReturn["JP06"] = "0";
                    dwReturn["JP07"] = "0";
                    dwReturn["JP08"] = "0";
                    dwReturn["JP09"] = "0";
                    dwReturn["JP10"] = "0";
                    dwReturn["JP11"] = "0";
                    dwReturn["JP12"] = "0";
                    dwReturn["JP13"] = "0";
                    dwReturn["JP14"] = "0";
                    dwReturn["JP15"] = "0";
                    dwReturn["JP16"] = "0";
                    dwReturn["JP17"] = "0";
                    dwReturn["JP18"] = "0";
                    dwReturn["JP19"] = "0";
                    dwReturn["JP20"] = "0";
                    dwReturn["JP21"] = "0";
                    dwReturn["JP22"] = "0";
                    dwReturn["JP23"] = "0";
                    dwReturn["JP24"] = "0";
                    dwReturn["JP25"] = "0";
                    dwReturn["JP26"] = "0";
                    dwReturn["JP27"] = "0";
                    dwReturn["JP28"] = "0";
                    dwReturn["JP29"] = "0";
                    dwReturn["JP30"] = "0";
                    dwReturn["JP31"] = "0";
                    dwReturn["JP32"] = "0";
                    dwReturn["JP33"] = "0";
                    dwReturn["JP34"] = "0";
                    dwReturn["JP35"] = "0";
                    dwReturn["JP36"] = "";
                    dwReturn["JP37"] = "";
                    dwReturn["JP38"] = "";
                    dwReturn["JP39"] = "";
                    dwReturn["JP41"] = "";
                    dwReturn["JP42"] = "";
                    dwReturn["JP43"] = "";
                    dwReturn["JP44"] = "";
                    dwReturn["JP45"] = "";
                    dwReturn["JP46"] = "";
                    dwReturn["JP47"] = "";
                    dwReturn["JP48"] = "";
                    dwReturn["JP49"] = "";
                    dwReturn["JP50"] = "";
                    break;
            }
        }
        public void InsertICC_SRULES(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            or1 = OracleDB.CreateCommand();
            switch (ITXDBVERSION)
            {
                default:
                case "50.24":
                    or1.CommandText = "INSERT INTO ICC_SRULES ( ROWNID,MACHINEID,RGROUP,RULEID,JOBV,JOBVDES,LOGIC,RVALUE,RULEDES,POINTS,JOBNUM,LASTEND,JMVALUE,JJVALUE,JOBID,JP01,JP02,JP03,JP04,JP05,JP06,JP07,JP08,JP09,JP10,JP11,JP12,JP13,JP14,JP15,JP16,JP17,JP18,JP19,JP20,JP21,JP22,JP23,JP24,JP25,JP26,JP27,JP28,JP29,JP30,JP31,JP32,JP33,JP34,JP35,JP36,JP37,JP38,JP39,JP41,JP42,JP43,JP44,JP45,JP46,JP47,JP48,JP49,JP50)"
                    + " VALUES (:ROWNID:,:MACHINEID:,:RGROUP:,:RULEID:,:JOBV:,:JOBVDES:,:LOGIC:,:RVALUE:,:RULEDES:,:POINTS:,:JOBNUM:,:LASTEND:,:JMVALUE:,:JJVALUE:,:JOBID:,:JP01:,:JP02:,:JP03:,:JP04:,:JP05:,:JP06:,:JP07:,:JP08:,:JP09:,:JP10:,:JP11:,:JP12:,:JP13:,:JP14:,:JP15:,:JP16:,:JP17:,:JP18:,:JP19:,:JP20:,:JP21:,:JP22:,:JP23:,:JP24:,:JP25:,:JP26:,:JP27:,:JP28:,:JP29:,:JP30:,:JP31:,:JP32:,:JP33:,:JP34:,:JP35:,:JP36:,:JP37:,:JP38:,:JP39:,:JP41:,:JP42:,:JP43:,:JP44:,:JP45:,:JP46:,:JP47:,:JP48:,:JP49:,:JP50:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);

                    break;
            }
            Connect2Proxy(or1);
        }

        public DataSet QueryICC_SRULES(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();
            switch (option)
            {
                case 1:
                    SResult = QSR01(dwData);
                    break;
                default:
                case 9999:
                    SResult = QSR00(dwData);
                    break;
            }
            return SResult;
        }
        public DataSet QSR01(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();

            or1.CommandText = "SELECT * FROM ICC_SRULES WHERE   ROWNID=:ROWNID:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QSR00(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();

            or1.CommandText = "SELECT * FROM ICC_SRULES ";
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QSR02(DataRow dwData, int option = 1)
        {

            or1 = OracleDB.CreateCommand();

            or1.CommandText = "SELECT * FROM ICC_SRULES WHERE   JOBNUM=:JOBNUM:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public void DSRULES01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM ICC_SRULES"
                + " WHERE ROWNID=:ROWNID:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public void DSRULES02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM ICC_SRULES";
            Connect2Proxy(or1);
        }
        public void UpdateICC_SRULES(DataRow dwData, int options = 1)
        {
            or1 = OracleDB.CreateCommand();
            switch (options)
            {
                default:
                case 1:
                    or1.CommandText = "UPDATE ICC_SRULES SET ROWNID=:ROWNID:,MACHINEID=:MACHINEID:,RGROUP=:RGROUP:,RULEID=:RULEID:,JOBV=:JOBV:,JOBVDES=:JOBVDES:,LOGIC=:LOGIC:,RVALUE=:RVALUE:,RULEDES=:RULEDES:,POINTS=:POINTS:,JOBNUM=:JOBNUM:,LASTEND=:LASTEND:,JMVALUE=:JMVALUE:,JJVALUE=:JJVALUE:,JOBID=:JOBID:,JP01=:JP01:,JP02=:JP02:,JP03=:JP03:,JP04=:JP04:,JP05=:JP05:,JP06=:JP06:,JP07=:JP07:,JP08=:JP08:,JP09=:JP09:,JP10=:JP10:,JP11=:JP11:,JP12=:JP12:,JP13=:JP13:,JP14=:JP14:,JP15=:JP15:,JP16=:JP16:,JP17=:JP17:,JP18=:JP18:,JP19=:JP19:,JP20=:JP20:,JP21=:JP21:,JP22=:JP22:,JP23=:JP23:,JP24=:JP24:,JP25=:JP25:,JP26=:JP26:,JP27=:JP27:,JP28=:JP28:,JP29=:JP29:,JP30=:JP30:,JP31=:JP31:,JP32=:JP32:,JP33=:JP33:,JP34=:JP34:,JP35=:JP35:,JP36=:JP36:,JP37=:JP37:,JP38=:JP38:,JP39=:JP39:,JP41=:JP41:,JP42=:JP42:,JP43=:JP43:,JP44=:JP44:,JP45=:JP45:,JP46=:JP46:,JP47=:JP47:,JP48=:JP48:,JP49=:JP49:,JP50=:JP50:"
                        + " WHERE ROWNID=:ROWNID:";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }
    }
}
